<?php
class Solvex
{
	/**
	 * Retrieve host
	 * 
	 * @return string
	 */
	public static function host()
	{
		return self::app()->getHost();
	}
	
	/**
	 * Website ID
	 * 
	 * @return int
	 */
	public static function siteId()
	{
		return 1;
	}
	
	/**
	 * Db object
	 * 
	 * @return Zend_Db_Adapter_Abstract
	 */
	public static function db()
	{
		return Zend_Registry::get('db');	
	}
	
	/**
	 * Application object
	 * 
	 * @return Solvex_Application
	 */
	public static function app()
	{
		return Zend_Registry::get('app');
	}

	/**
	 * Frontcontroller object
	 * 
	 * @return Zend_Controller_Front
	 */	
	public static function front()
	{
		return Zend_Controller_Front::getInstance();
	}
	
	/**
	 * Debug
	 */	
	public static function debug($var)
	{
		Zend_Debug::dump($var,'--- SOLVEX DEBUG ---');		
	}
	
	/**
	 * Website object
	 * 
	 * @return Core_Model_Website
	 */
	public static function website()
	{
		return Zend_Registry::get('website');
	}
	
	/**
	 * Cache object
	 * 
	 * @return Zend_Cache_Core
	 */	
	public static function cache()
	{
		return Zend_Registry::get('cache');
	}
	
	/**
	 * Config object
	 * 
	 * @param string $path
	 * @param int $siteId
	 * @param mixed $default
	 * @return Solvex_Config|Zend_Config|string
	 */
	public static function config($path = null, $siteId = null, $default = null)
	{
		$config = Zend_Registry::get('config');
		if(null !== $path){
			return $config->getNode($path,$siteId,$default);
		}
		return $config;
	}
	
	/**
	 * Translation object
	 * 
	 * @return Solvex_Translate
	 */
	public static function translate($module = 'core')
	{
		return Solvex_Translate::getInstance($module);
	}
	
	/**
	 * DB Table object
	 * 
	 * @param string $tableName
	 * @param array $args
	 * @return Solvex_Db_Table
	 */
	public static function table($tableName = null, array $args = array())
	{
		return new Solvex_Db_Table(array_merge(
			$args, array('name' => $tableName)
		));
	}
	
    /**
     * Retrieve session object
     *
     * @static
     * @return Zend_Session_Namespace
     */
    public static function session($namespace = 'main')
    {
        if (!Zend_Registry::isRegistered($namespace)) {
            Zend_Registry::set($namespace, new Zend_Session_Namespace($namespace));
        }
        return Zend_Registry::get($namespace);
    }
}